package com.aj.http.response;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

public class Common implements Serializable {
	private static final long serialVersionUID = 4103161377736059046L;
	private String returnCode;
	private String serviceName;
	private String errorMsg;
	private JSONObject result;

	public Common() {
	}

	public Common(JSONObject json) throws JSONException {
		super();
		init(json);
	}

	private void init(JSONObject json) throws JSONException {
		if (json != null) {
			if (!json.isNull("returnCode")) {
				try {
					returnCode = json.getString("returnCode");
				} catch (JSONException e) {
					returnCode = "000001";
				}
			}

			if (!json.isNull("serviceName")) {
				serviceName = json.getString("serviceName");
			}
			if (!json.isNull("errorMsg")) {
				errorMsg = json.getString("errorMsg");
			}
			if (!json.isNull("result")) {
				result = json.getJSONObject("result");
				if (!result.isNull("succMsg")) {
					errorMsg = result.getString("succMsg");
				} else {
					errorMsg = json.getString("errorMsg");
				}
			} else {
				errorMsg = json.getString("errorMsg");
			}
		}
	}

	public String getReturnCode() {
		return returnCode;
	}

	public void setReturnCode(String returnCode) {
		this.returnCode = returnCode;
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public JSONObject getResult() {
		return result;
	}

	public void setResult(JSONObject result) {
		this.result = result;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

}
